﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class org_manUser_new : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void tb_username_TextChanged(object sender, EventArgs e)
    {
        if (MasApp.BLL.Search.HaveUsername(tb_username.Text))
        {
            Label1.Visible = true;
        }
        else
        {
            Label1.Visible = false;
        }
    }
    protected void ImageButton1_Click(object sender, EventArgs e)
    {
        
        #region Model us
        MasApp.Model.users us = new MasApp.Model.users();
        us.Address = tb_address.Text;
        us.Description = tb_description.Text;
        us.Email = tb_email.Text;
        us.Mphone = tb_mphone.Text;
        us.Organizationid = MasApp.BLL.Search.SearchOrgID(Session["username"].ToString());
        us.Phone = tb_phone.Text;
        us.Postcode = tb_postcode.Text;
        us.Realname = tb_realname.Text;
        us.Sex = DropDownList1.SelectedValue;
        us.Username = tb_username.Text;
        #endregion
        #region Model ur
        MasApp.Model.userrole ur = new MasApp.Model.userrole();
        ur.Roleid = 4;
        #endregion
        #region Model log
        MasApp.Model.login log = new MasApp.Model.login();
        log.Username = tb_username.Text;
        log.Password = tb_password.Text;
        #endregion
        #region 显示成功与否
        form1.Controls.Clear();
        if (MasApp.BLL.reg.AddRole4(log, us, ur))
        {
            Response.Write("<font color='red' size='14px'>用户：" + tb_username.Text + "添加成功！</font>");
        }
        else
        {
            Response.Write("<font color='red' size='14px'>操作失败！</font>");
        }
        #endregion

    }
}
